package com.zhouxl.finished;

import org.springframework.context.ApplicationEvent;
import org.springframework.context.event.SmartApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * 微信发布监听器
 * @author zhouxl
 * @DATE 2021/6/22
 * @descriptoin
 */
@Component
public class FinishedWechatListener implements SmartApplicationListener {

    @Override
    @Async
    public void onApplicationEvent(ApplicationEvent applicationEvent) {
        FinishedOrderCreateEvent event = (FinishedOrderCreateEvent) applicationEvent;
        //发送微信
        System.out.println(event.getArgs().get(0) + ",您的订单:" + event.getArgs().get(1) + "创建成功! ----by wechat");

    }
    @Override
    public boolean supportsEventType(Class<? extends ApplicationEvent> aClass) {
        return aClass == FinishedOrderCreateEvent.class;
    }

    @Override
    public int getOrder() {
        return 1;
    }
}
